package Items;

import java.io.Serializable;

/**
 * Item: Abstract representation of an Item to be bought, sold, and used in the game. 
 * Each item has a base price, a klepton amount, and a description.
 * 
 * @author Branon Lyle
 */
public abstract class Item implements Serializable{
    
    private int basePrice;
    private int kleptons;
    private int quantity;
    private String description;
    
    /**
     * Constructor
     * @param basePrice base price
     * @param kleptons  time space value
     * @param quantity  number available
     * @param description   what is it
     */
    public Item(int basePrice, int kleptons, int quantity, String description) {
        this.basePrice = basePrice;
        this.kleptons = kleptons;
        this.quantity = quantity;
        this.description = description;
    }
    
    /**
     * basePrice Accessor
     * @return int basePrice
     */
    public int getBasePrice() {
        return basePrice;
    }
    
    /**
     * basePrice Modifier
     * @param basePrice the intended price of the item
     */
    public void setBasePrice(int basePrice) {
        this.basePrice = basePrice;
    }
    
    /**
     * Kleptons Accessor
     * @return int kleptons
     */
    public int getKlepton() {
        return kleptons;
    }
    
    /**
     * Kleptons Mutator
     * @param kleptons the intended kleptons of this Item 
     */
    public void setKleptons(int kleptons) {
        this.kleptons = kleptons;
    }
    
    /**
     * Quanity Accessor
     * @return quantity
     */
    public int getQuantity() {
        return quantity;
    }
    
    /**
     * Quantity Mutator
     * @param quantity the intented quantity for this Item
     */
    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }
    
    /**
     * Adds/subtracts from this Items quantity the inputed change
     * @param change
     */
    public void modifyQuantity(int change) {
        if ((this.quantity + change) >= 0)
            this.quantity += change;
        else
            System.out.println("You don't have that many Items");
    }
    
    /**
     * description Accessor
     * @return description
     */
    public String getDescription() {
        return description;
    }
    
    /**
     * Modifies the base price given the inputed modifier and returns
     * this new price
     * @param modifier the modifier for the base price
     */
    public int modifyPrice(int modifier) {
        return modifier*basePrice;
    }
    
    /**
     * String representation of the Item
     */
    public abstract String toString();
    
    /**
     * Determines if this Item and the inputed object are equal
     * @return true if the inputed object has the same String representation as this Item
     */
    public boolean equals(Object o) {
        if (this.toString().equals(o.toString()))
            return true;
        else
            return false;
    }
    
}
